﻿using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

using SwyishChess.Domain.ChessGame;
using SwyishChess.Service;

namespace SwyishChess.DesktopUI
{
    public partial class StartWindow : Window
    {
        public StartWindow()
        {
            InitializeComponent();
            /* Puts the windows in the center of the screen */
            WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
        }

        /// <summary>
        /// Start button click event
        /// </summary>
        /// <param name="sender">Start button object</param>
        /// <param name="e"></param>
        void ButtonStart_Click(object sender, RoutedEventArgs e)
        {
            ChessGameModel chessGameModel = null;

            /* Hides the current window */
            this.Visibility = Visibility.Hidden;

            /* Instantiate ChessGameModel class with appropirate integer value depending on player mode selected by user */
            if (TwoPlayerModeRadioButton.IsChecked == true)
            {
                chessGameModel = new ChessGameModel();
            }
            else if (OnePlayerModeRadioButton.IsChecked == true)
            {
                chessGameModel = new ChessGameModel();
            }

            // TODO: USE UNITY
            /* Create and display the window */
            MainWindow mw = new MainWindow(chessGameModel, new MoveValidationService(), new MoveTrackingService(),
                new SpecialMoveService());
            mw.Show();
        }

        /// <summary>
        /// Two player mode radio button click event
        /// </summary>
        /// <param name="sender">Radio button object</param>
        /// <param name="e"></param>
        void TwoPlayerModeRadioButton_Click(object sender, RoutedEventArgs e)
        {
            buttonStart.IsEnabled = true;
        }

        /// <summary>
        /// Quit button click event
        /// </summary>
        /// <param name="sender">Quit button object</param>
        /// <param name="e"></param>
        private void buttonQuit_Click(object sender, RoutedEventArgs e)
        {
            /* Shuts down the aplication */
            Application.Current.Shutdown();
        }
    }
}
